home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12434 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: formatting integers
  5. Date: Sat, 30 Mar 96 21:39:56 GMT
  6. Organization: none
  7. Distribution: usa
  8. Message-ID: <828221996snz@genesis.demon.co.uk>
  9. References: <4jfmsh$lal@uwm.edu>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <4jfmsh$lal@uwm.edu>
  16.            gidwani@alpha1.csd.uwm.edu "Vinay K Gidwani" writes:
  17.  
  18. >I am trying to format an integer that is left justified, length of 4 and
  19. >0 filled.
  20.  
  21. That makes no sense. If it is left justified there is nowhere to zero fill.
  22. If printf zero filled to the right it would be printing the wring number
  23. so it can't do that.
  24.  
  25. >
  26. >I tried the following %-0*%d and typed in the length of 4, but it gave me
  27. >the following output
  28.  
  29. >    4.
  30. >    When I try %0*d, then I get the following output.
  31. >    0004. 
  32. >    The length and the 0 filled in works but I cannot get it to left
  33. >    justify.
  34.  
  35. Give an example of the output you actually want.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.